package com.CuiChangHe.studentmanager.mapper;

import com.CuiChangHe.studentmanager.dao.StudentLeaveInfoDao;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

/**
 * @Description :学生请销假信息Mapper
 * @Author :崔昌赫
 * @Date : 2021/11/19
 */
@Mapper
@Repository
public interface StudentLeaveInfoMapper {
   @Select("SELECT * FROM studentleave WHERE 1=1")
   StudentLeaveInfoDao [] findAllStudentLeaveInfo();
   @Select("SELECT * FROM studentleave WHERE is_non_checked = 'true' AND is_non_report = 'true'")
   StudentLeaveInfoDao [] findAllNon_CheckedStudentLeaveInfo();
   @Select("SELECT * FROM studentleave WHERE is_non_checked = 'false' AND is_non_report = 'true'")
   StudentLeaveInfoDao [] findAllNon_ReportStudentLeaveInfo();
   @Select("SELECT * FROM studentleave WHERE is_non_checked = 'false' AND is_non_report = 'false'")
   StudentLeaveInfoDao [] findAllFinishStudentLeaveInfo();
   @Insert("INSERT INTO studentleave VALUES (" +
           "null," +
           "'${data.identifier}'," +
           "'${data.studentid}'," +
           "'${data.name}'," +
           "'${data.status}'," +
           "'${data.college}'," +
           "'${data.classes}'," +
           "'${data.start}'," +
           "'${data.end}'," +
           "'${data.time}'," +
           "'${data.teacher_name}'," +
           "'${data.reason}'," +
           "'${data.is_non_checked}'," +
           "'${data.is_non_report}'" +
           ")")
   Boolean addNewLeaveInfo(@Param("data") StudentLeaveInfoDao data);

   @Update("UPDATE studentleave SET is_non_checked = 'false' WHERE identifier = '${identifier}'")
   Boolean Check(@Param("identifier") String identifier);
   @Update("UPDATE studentleave SET is_non_report = 'false' WHERE identifier = '${identifier}'")
   Boolean Report(@Param("identifier") String identifier);

   @Select("SELECT * FROM studentleave WHERE identifier = '${identifier}'")
   StudentLeaveInfoDao findStudentLeaveInfoByIdentifier(@Param("identifier") String identifier);

   @Update("UPDATE studentleave SET status= '${status}' WHERE identifier = '${identifier}'")
   Boolean updateStudentLeaveInfoStatusByIdentifier(@Param("identifier") String identifier,@Param("status")String status);
}
